package cn.xspace.module.other.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;

import com.xspace.android.xafcommon.base.BaseAct;

import java.util.HashMap;
import java.util.Map;

import cn.xspace.module.other.util.RProxy;
import de.greenrobot.event.EventBus;

public class SexSetAct extends BaseAct {
	private String user_sex = "";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(RProxy.sexsetact);
		initViews();
	}

	private void initViews() {
		setTitleBarBg(findViewById(RProxy.r_item));
		setTitleBarBg(findViewById(RProxy.btn_sex_ok));
		
		String sex = getIntent().getStringExtra("SexSetActivity");
		user_sex=sex;
		if ("男".equals(sex)) {
			((ImageView) findViewById(RProxy.iv_sex_man))
					.setBackgroundResource(RProxy.btn_check_on_normal);
			((ImageView) findViewById(RProxy.iv_sex_lady))
					.setBackgroundResource(RProxy.btn_check_off_normal);
		} else {
			((ImageView) findViewById(RProxy.iv_sex_lady))
					.setBackgroundResource(RProxy.btn_check_on_normal);
			((ImageView) findViewById(RProxy.iv_sex_man))
					.setBackgroundResource(RProxy.btn_check_off_normal);
		}
	}

	public void onClick(View v) {
		Intent intent = new Intent();
			Map<String,String> map=new HashMap<String, String>();
		if(v.getId()==RProxy.iv_sex_man){
			user_sex = "男";
//			intent.putExtra("UserInfoAct", user_sex);// 把返回数据存入Intent
//			setResult(UserInfoAct.SEXSET_FORREULR, intent);
			map.put("type","SexSetAct");
			map.put("UserInfoAct",user_sex);
			map.put("sure_ok","true");
			EventBus.getDefault().post(map);
			finish();
		}else if(v.getId()==RProxy.iv_sex_lady){
			user_sex = "女";
//			intent.putExtra("UserInfoAct", user_sex);// 把返回数据存入Intent
//			setResult(UserInfoAct.SEXSET_FORREULR, intent);
			map.put("type","SexSetAct");
			map.put("UserInfoAct",user_sex);
			map.put("sure_ok","true");
			EventBus.getDefault().post(map);
			finish();
		}else if(v.getId()==RProxy.btn_sex_ok){
			map.put("type","SexSetAct");
			map.put("UserInfoAct",user_sex);
			map.put("sure_ok","true");
			EventBus.getDefault().post(map);
			finish();
		}


	}
	/*
	 * public boolean onKeyDown(int keyCode, KeyEvent event) {
	 * 
	 * startActivity(new Intent(this,AccountSettingActivity.class)); return
	 * true; }
	 */
}
